﻿@{
    Bundle("jquery_timepicker");
    Bundle("jquery_validate");
}

<script type="text/javascript">
    jQuery(document).ready(function(){
        jQuery('@ID("#form")').validate({
            rules: {
                authorName: {
                    required: true
                },
                publishedOn: {
                    required: true
                },
                code: {
                    required: true
                },
                fileGroupID: {
                    required: true,
                    digits: true
                }
            }
        });
        jQuery('@ID("#txt_published")').datetimepicker();
        jQuery('@ID("#txt_author")').autocomplete({
            source: function (request, response) {
                jQuery.post('@Html.Raw(Url.Action(Loc.Act("Autocomplete").Ctrl("Author")))', request, response);
            },
            minLength: 3,
            select: function (event, ui) {
                jQuery('@ID("#hidden_author")').val(ui.item.id);
            }
        });
    });
</script>
<form id="@ID("form")" action="@Url.Action(Loc.Act("Create"))" method="post">
    <input type="hidden" name="flags" value="None" />
    <table>
        <tr>
            <td>
                <label>@T(Res.Name("Author"))</label>
            </td>
            <td>
                <input id="@ID("hidden_author")" type="hidden" name="authorID" />
                <input id="@ID("txt_author")" type="text" name="authorName" />
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.Name("PublishedOn"))</label>
            </td>
            <td>
                <input id="@ID("txt_published")" type="text" name="publishedOn" value="@Svc.DateTime(DateTime.UtcNow)" />
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.In("Common").Of("Vocab").Name("Code"))</label>
            </td>
            <td>
                <input type="text" name="code" value="@StringHelper.Random(10)" maxlength="10" />
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.Name("FileGroup"))</label>
            </td>
            <td>
                <input type="text" name="fileGroupID" value="0" />
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.Name("Type"))</label>
            </td>
            <td>
                <ul class="bar">
                    <li>
                        <input type="radio" name="flags" value="News" />
                    </li>
                    <li>
                        <label>@T(Res.In("API").Of("Enum").Of("PublicationFlags").Name("News"))</label>
                    </li>
                    <li>
                        <input type="radio" name="flags" value="Article" />
                    </li>
                    <li>
                        <label>@T(Res.In("API").Of("Enum").Of("PublicationFlags").Name("Article"))</label>
                    </li>
                    <li>
                        <input type="radio" name="flags" value="Advertisement" />
                    </li>
                    <li>
                        <label>@T(Res.In("API").Of("Enum").Of("PublicationFlags").Name("Advertisement"))</label>
                    </li>
                    <li>
                        <input type="radio" name="flags" value="BlogPost" />
                    </li>
                    <li>
                        <label>@T(Res.In("API").Of("Enum").Of("PublicationFlags").Name("BlogPost"))</label>
                    </li>
                </ul>
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.In("API").Of("Enum").Of("PublicationFlags").Name("Active"))</label>
            </td>
            <td>
                <input type="checkbox" name="flags" value="Active" />
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.In("API").Of("Enum").Of("PublicationFlags").Name("RatingAllowed"))</label>
            </td>
            <td>
                <input type="checkbox" name="flags" value="RatingAllowed" />
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.In("API").Of("Enum").Of("PublicationFlags").Name("AnonRatingAllowed"))</label>
            </td>
            <td>
                <input type="checkbox" name="flags" value="AnonRatingAllowed" />
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.In("API").Of("Enum").Of("PublicationFlags").Name("CommentAllowed"))</label>
            </td>
            <td>
                <input type="checkbox" name="flags" value="CommentAllowed" />
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.In("API").Of("Enum").Of("PublicationFlags").Name("AnonCommentAllowed"))</label>
            </td>
            <td>
                <input type="checkbox" name="flags" value="AnonCommentAllowed" />
            </td>
        </tr>
    </table>
    <ul class="bar toolbar">
        <li><button class="button" type="submit">@T(Res.In("Common").Of("Act").Name("Submit"))</button></li>
    </ul>
</form>